//
//  HMImUserInfo.swift
//  HealthMonitoring
//
//  Created by YTYanK on 2018/10/28.
//  Copyright © 2018年 YTYanK. All rights reserved.
//
/**
 一个用户信息类  --- 可以后面继续加内容 -- 默认直接获取当前用户资料
 **/
import UIKit

class HMImUserInfo: NSObject, IMUIUserProtocol {
    
    var im_displayName = ""
    var im_avatar = UIImage()
    var im_userId = ""
    var urlImg = ""
    
    public override init() {
        super.init()
        let dic  =  HMLoginParam.share.user
        self.im_userId =   dic["id"] as! String
        self.im_displayName =  dic["nickname"] as! String
        self.im_avatar = HMLoginParam.share.getCurrentImage
        //self.urlImg =  configure.shareConfigure.IP_diagonal + (dic["iconUrl"] as! String)
    }
    
    func userId() -> String {
        return self.im_userId
    }
    
    func displayName() -> String {
        return self.im_displayName
    }
    func Avatar() -> UIImage {
  
//        if HMLoginParam.share.getCurrentImage != nil {
//            return HMLoginParam.share.getCurrentImage!
//        }else {
//            self.im_avatar = "device_"
//            return UIImage(named: self.im_avatar)!
//        }
        if urlImg.count > 0 {
             let v =  UIImageView()
                v.img(url: urlImg)
            return v.image!
//            self.im_avatar = "device_"
//            return UIImage(named: self.im_avatar)!
        }else {
            return self.im_avatar
        }
        
    }
}
